package com.umeng.soexample.mvp.model;

import com.umeng.lib_core.http.MResponseManager;
import com.umeng.lib_core.mvp.model.BaseModel;
import com.umeng.soexample.bean.BaseEntity;
import com.umeng.soexample.bean.HomeBannerEntity;
import com.umeng.soexample.bean.HomeGoodsEntity;
import com.umeng.soexample.bean.HomeRecommendEntity;
import com.umeng.soexample.mvp.contract.HomeFragmentContract;
import com.umeng.soexample.network.API;

import java.util.Map;

import javax.inject.Inject;

import io.reactivex.Observable;

public class HomeFragmentModel extends BaseModel implements HomeFragmentContract.HomeFragmentIModel {

    @Inject
    public HomeFragmentModel(){}

    @Override
    public Observable<BaseEntity> request(Map<String, String> map) {
        Observable<HomeBannerEntity> banner = MResponseManager.obtainRetrofit(API.class).home_banner_request();
        Observable<HomeRecommendEntity> recommend = MResponseManager.obtainRetrofit(API.class).home_recommend_request(map.get("recommend"));
        Observable<HomeGoodsEntity> goods = MResponseManager.obtainRetrofit(API.class).home_goods_request(map.get("goods"));
        return Observable.merge(banner, recommend, goods);
    }

    @Override
    public Observable<HomeGoodsEntity> requestGoods(String requst) {
        return MResponseManager.obtainRetrofit(API.class).home_goods_request(requst);
    }

    @Override
    public void destroy() {

    }
}
